package com.xuecheng.search.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Es配置
 *
 * @author 七安
 */
@Configuration
public class EsConfig {

    @Value("${xuecheng.elasticsearch.http-host}")
    private String httphost;

    @Bean
    public RestHighLevelClient restHighLevelClient() {
        HttpHost httpHost = HttpHost.create(httphost);
        return new RestHighLevelClient(RestClient.builder(httpHost));
    }
}
